//
//  BdjlCell.swift
//  Auscultation
//
//  Created by 来 on 2020/12/11.
//

import Foundation

class BdjlCell: UICollectionViewCell {

    var tzyb: UILabel!
    var xm: UILabel!
    var nl: UILabel!
    var xb: UILabel!
    
    var bdjl_delete: (() -> Void)?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.backgroundColor = UIColor.white
        
        tzyb = UILabel.init()
        tzyb.text = "听诊样本"
        tzyb.lgf_AddShowAllText()
        tzyb.font = UIFont.systemFont(ofSize: 18)
        tzyb.textColor = UIColor.init(lgf_HexString: "222222")
        addSubview(tzyb)
        tzyb.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview().multipliedBy(0.6)
            make.left.equalToSuperview().offset(17)
        }
        
        xm = UILabel.init()
        xm.text = "姓名："
        xm.lgf_AddShowAllText()
        xm.font = UIFont.systemFont(ofSize: 14)
        xm.textColor = UIColor.init(lgf_HexString: "8D969D")
        addSubview(xm)
        xm.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview().multipliedBy(1.4)
            make.left.equalToSuperview().offset(17)
        }
        
        nl = UILabel.init()
        nl.text = "年龄："
        nl.lgf_AddShowAllText()
        nl.font = UIFont.systemFont(ofSize: 14)
        nl.textColor = UIColor.init(lgf_HexString: "8D969D")
        addSubview(nl)
        nl.snp.makeConstraints { (make) in
            make.centerY.equalTo(xm)
            make.left.equalTo(xm.snp.right).offset(10)
        }
        
        xb = UILabel.init()
        xb.text = "性别："
        xb.lgf_AddShowAllText()
        xb.font = UIFont.systemFont(ofSize: 14)
        xb.textColor = UIColor.init(lgf_HexString: "8D969D")
        addSubview(xb)
        xb.snp.makeConstraints { (make) in
            make.centerY.equalTo(xm)
            make.left.equalTo(nl.snp.right).offset(10)
        }
        
        let delete = UIImageView.init(image: #imageLiteral(resourceName: "shanchu"))
        delete.isUserInteractionEnabled = true
        delete.lgf_AddTap(target: self, action: #selector(BdjlCell.s_delete))
        addSubview(delete)
        delete.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(-17)
            make.width.height.equalTo(30)
        }
        
        let line3 = UIView.init()
        line3.backgroundColor = UIColor.init(lgf_HexString: "F1F2F4")
        addSubview(line3)
        line3.snp.makeConstraints { (make) in
            make.centerX.bottom.equalToSuperview()
            make.width.equalToSuperview().offset(-34)
            make.height.equalTo(1)
        }
        
    }
    
    @objc func s_delete() {
        let alertVC = UIAlertController.init(title: nil, message: "是否删除本条记录？", preferredStyle: .alert)
        alertVC.addAction(UIAlertAction.init(title: "确定", style: .destructive, handler: { [weak self] (action) in
            self?.bdjl_delete?()
        }))
        alertVC.addAction(UIAlertAction.init(title: "取消", style: .cancel, handler: { (action) in
        }))
        UIApplication.shared.keyWindow?.rootViewController?.present(alertVC, animated: true, completion: nil)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
